<template>
    <div class="app-container">
        <div v-if="user">
            <el-row :gutter="20">
                <el-col :span="6" :xs="24">
                    <user-card :user="user" />
                </el-col>

                <el-col :span="18" :xs="24">
                    <el-card>
                        <el-tabs v-model="activeTab">
                            <el-tab-pane label="Activity" name="checkincalendar">
                                <check-in-calendar :user="user"/>
                            </el-tab-pane>
                            <el-tab-pane label="个人信息" name="userinfo">
                                <user-info :user="user" />
                            </el-tab-pane>
                            <el-tab-pane label="修改密码" name="account">
                                <account :user="user" />
                            </el-tab-pane>
                        </el-tabs>
                    </el-card>
                </el-col>

            </el-row>
        </div>
    </div>
</template>

<script>
    import { mapGetters } from 'vuex'
    import UserCard from './components/UserCard'
    import Account from './components/Account'
    import UserInfo from "./components/UserInfo"
    import CheckInCalendar from "./components/CheckInCalendar";

    export default {
        name: "UserCenter",
        components: { UserCard, Account,UserInfo,CheckInCalendar },
        data() {
            return {
                user: JSON.parse(window.sessionStorage.getItem('user')),
                activeTab: 'checkincalendar'
            }
        },
        computed: {
            ...mapGetters([
                'name',
                'avatar',
                'roles'
            ])
        },
        created() {
            this.getUser()
        },
        methods: {
            getUser() {
                this.user = JSON.parse(window.sessionStorage.getItem('user'))
            }
        }
    }
</script>

<style scoped>

</style>